package org.catdroid.bcnappsjam.barcelonaparticipa.util;

import org.catdroid.bcnappsjam.barcelonaparticipa.R;

import android.app.Activity;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;

public class LoadingIconUtil {
	public static void startLoading(Activity a) {
		Animation rotation = AnimationUtils.loadAnimation(a, R.anim.loadingrotation);
		View v = a.findViewById(R.id.loading);
		if (v != null) {
			if (v.getAnimation() == null) {
				v.startAnimation(rotation);
			}
			v.setVisibility(View.VISIBLE);
		}
	}

	public static void stopLoading(Activity a) {
		View v = a.findViewById(R.id.loading);
		if (v != null) {
			v.clearAnimation();
			v.setVisibility(View.GONE);
		}
	}

	public static void stopLoadingInvisible(Activity a) {
		View v = a.findViewById(R.id.loading);
		if (v != null) {
			v.clearAnimation();
			v.setVisibility(View.INVISIBLE);
		}
	}
}
